import { PageContainer } from "@ant-design/pro-components";
import { Button, Modal, Input, Form, Radio, Select, Space } from "antd";
import { connect, useParams } from "umi";
import dayjs from "dayjs";
import { namespace } from "./configFile";
import { useEffect, useRef, useState } from "react";
import "@wangeditor/editor/dist/css/style.css"; // 引入 css
import { Editor, Toolbar } from "@wangeditor/editor-for-react";
const Page = (props) => {
  const { dispatch, submitLoading, data } = props;
  // 编辑器内容
  const objData = useParams();
  useEffect(() => {
    dispatch({
      type: `${namespace}/pageInit`,
      params: {
        id: objData.id,
      },
    });
  }, []);

  return (
    <PageContainer>
      <div>
        <h2 style={{ textAlign: "center", marginBottom: "10px" }}>
          {data.noticeTitle}
        </h2>
        <div style={{ textAlign: "center", marginBottom: "30px" }}>
          发布日期：{dayjs(data.createTime).format("YYYY-MM-DD")}
        </div>
        <div>
          <div dangerouslySetInnerHTML={{ __html: data.noticeContent }}></div>
        </div>
      </div>
    </PageContainer>
  );
};

export default connect((state) => ({
  ...state[namespace],
  submitLoading: state.loading.effects[`${namespace}/submitItem`],
}))(Page);
